setTextFontWeightAndStyle

abstract fun setTextFontWeightAndStyle(block: DesignBlock, fontWeight: FontWeight, fontStyle: FontStyle, from: Int = -1, to: Int = -1)

Changes the weight and the style of the text in the selected range in one step. Each run gets the font of its typeface with exactly this weight and style. Separate calls to setTextFontWeight and setTextFontStyle pass through a face in between, so they fail when the typeface lacks that face. Required scope: "text/character"

Parameters

block

the text block whose weight and style should be changed.

fontWeight

the new weight of the selected text range.

fontStyle

the new style of the selected text range.

from

the start index of the UTF-16 range whose weight and style should be changed. If the value is negative and the block is currently being edited, this will fall back to the start of the current cursor index / selected grapheme range. If the value is negative and the block is not being edited, this will fall back to the start of the entire text range.

to

the UTF-16 index after the last grapheme whose weight and style should be changed. If the value is negative and the block is currently being edited, this will fall back to the end of the current cursor index / selected grapheme range. If the value is negative and the block is not being edited, this will fall back to the end of the entire text range.

Throws

with code BLOCK.TEXT_UNSUPPORTED_FONT_FACE when the typeface of a run has no font with this weight and style. That run keeps its font, and the other runs of the range change. A run with a font request from setFontRequest takes the face into its request and gets no error.